﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MetaTracker.ViewModel;
using System.Diagnostics;

namespace MetaTracker.View
{
    /// <summary>
    /// Interaction logic for StatisticsView.xaml
    /// </summary>
    public partial class StatisticsView : UserControl
    {
        bool DeferedLoad = false;

        public StatisticsView()
        {
            InitializeComponent();

            if (DataContext == null || !(DataContext is StatisticsViewModel))
            {
                DataContext = new StatisticsViewModel();
            }
        }

        #region EventHandeling
        private void StatisticsView_Loaded(object sender, RoutedEventArgs e)
        {

            if (DeferedLoad == false)
            {
                DeferedLoad = true;
            }
            else if( DataContext != null && (DataContext is StatisticsViewModel))
            {
                (DataContext as StatisticsViewModel).BuildStatistics(false);
            }
        }
        private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
            e.Handled = true;
        }
        #endregion //EventHandeling
    }
}
